package com.tsingteng.cosfun.ui.found;

import com.tsingteng.cosfun.bean.DataBean;
import com.tsingteng.cosfun.bean.FoundBean;
import com.tsingteng.cosfun.callback.RxObserver;
import com.tsingteng.cosfun.mvp.presenter.BasePresenter;

/**
 * 网络请求具体实现
 * author zht
 */
public class FoundPresenter extends BasePresenter<FoundContact.IFoundView> implements FoundContact.IFoundPresenter{

    FoundContact.IFoundView mIFoundView;
    FoundModel mFoundModel;
    public FoundPresenter(){
        this.mFoundModel=new FoundModel();
    }
    @Override
    public void getActivityList(int page_no) {
        mIFoundView = getView();
        RxObserver<FoundBean> rxObserver=new RxObserver<FoundBean>(this) {
            @Override
            protected void onFaile(int errorCode, String errorMsg) {
                mIFoundView.showFail(errorMsg);
            }

            @Override
            protected void onSuccess(FoundBean foundBean) {
                mIFoundView.showActivityList(foundBean);
            }
        };
        mFoundModel.getFoundActivity(page_no,rxObserver);
        addDisposable(rxObserver);
    }

    @Override
    public void readActivity(long activityId) {
        mIFoundView = getView();
       RxObserver<DataBean> rxObserver=new RxObserver<DataBean>(this) {
           @Override
           protected void onFaile(int errorCode, String errorMsg) {
               mIFoundView.showFail(errorMsg);
           }

           @Override
           protected void onSuccess(DataBean integer) {
                mIFoundView.showReadActivity();
           }
       };
       mFoundModel.readFoundActivity(activityId,rxObserver);
       addDisposable(rxObserver);
    }
}
